﻿<%@ WebHandler Language="C#" Class="UserIsExsistHandler" %>

using System;
using System.Web;
using System.Collections.Generic;
using System.Data;

using Cisoft.IntegrationSystem.BLL;
using Cisoft.IntegrationSystem.Model;

using Cisoft.Cisoft3G.BLL;
using Cisoft.Cisoft3G.Model;

public class UserIsExsistHandler : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        //context.Response.Write("Hello World");

       

        if (context.Request["UserName"] != null && !string.IsNullOrEmpty(context.Request["UserName"].ToString()))
        {
            UserBO bll = new UserBO();
            UserMO model = new UserMO();
            string name = context.Request["UserName"].ToString();
            DataSet ds = bll.GetUserList(" US_UserName = '" + name + "' ");
            if (ds.Tables[0].Rows.Count > 0)
            {
                //已经存在
                context.Response.Write("1");
            }
            else
            {
                //不存在
                context.Response.Write("0");
            }
        }
        if (context.Request["Mobile"] != null && !string.IsNullOrEmpty(context.Request["Mobile"].ToString()))
        {
            ContactsBO bll = new ContactsBO();
            ContactsMO model = new ContactsMO();
            
            string mobile = context.Request["Mobile"].ToString();
            DataSet ds = bll.GetList(" CT_Mobile = '" + mobile + "' ");
            if (ds.Tables[0].Rows.Count > 0)
            {
                //已经存在
                context.Response.Write("1");
            }
            else
            {
                //不存在
                context.Response.Write("0");
            }
        }
        if (context.Request["om"] != null && !string.IsNullOrEmpty(context.Request["om"].ToString()))
        {
            if (context.Request["nm"] != null && !string.IsNullOrEmpty(context.Request["nm"].ToString()))
            {
                string oldmobile = context.Request["om"].ToString();
                string newmobile = context.Request["nm"].ToString();
                
                ContactsBO bll = new ContactsBO();
                ContactsMO model = new ContactsMO();

                DataSet ds = bll.GetList(" CT_Mobile = '" + oldmobile + "' and CT_Mobile<>'" + oldmobile + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    //已经存在
                    context.Response.Write("1");
                }
                else
                {
                    //不存在
                    context.Response.Write("0");
                }
            }
        }
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}